<?php
JunctionFileCabinet::using("Junction_Clause_Builder");
JunctionFileCabinet::using("Junction_Utils_Arrays");

class Junction_Clause_Conjunction implements Junction_Clause_Builder {
	
	private $_conditions;
	
	private $_value;
	
	public function __construct() {
		$this->_conditions = array();
		$this->_value = array();
	}
	
	public function bindCondition($expression, $value = null) {
		$this->_conditions[] = $expression;
		if (isset($value)) {
			$this->_value[] = $value;
		}
	}
	
	public function toSql() {
		$clause = current($this->_conditions);
		while (next($this->_conditions)) {
			$clause .= " AND " . current($this->_conditions);
		}
		return (strlen($clause) > 0) ? " WHERE " . $clause : "";
	}
	
	public function getValues() {
		return $this->_value;
	}
}
?>